home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77691_Text_Log_clear.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  7.4 KB  |  210 lines

  1. <%@Language=VbScript%>
  2. <% Option Explicit     %>
  3.  
  4. <%    '------------------------------------------------------------------------- 
  5.     ' Text_Log_Clear.asp : This page serves in Deleting the log file
  6.     ' Copyright (c) Microsoft Corporation.  All rights reserved.
  7.     '-------------------------------------------------------------------------
  8. %>
  9.     <!--  #include virtual="/admin/inc_framework.asp"--->
  10.     <!-- #include file="loc_Log.asp" -->
  11. <% 
  12.     '-------------------------------------------------------------------------
  13.     ' Form Variables
  14.     '-------------------------------------------------------------------------    
  15.     Dim F_strFileToDelete                ' the file to be deleted
  16.     Dim F_arrFilesToDelete                 ' the files to be deleted    
  17.     Dim F_strFilesPath                     ' path of the files to be deleted.    
  18.     Dim F_strFilesSubmit                 ' variable to hold all the files as a string.    
  19.     Dim F_arrFilesSubmitToDelete         ' array variable to hold all the files submitted to delete.    
  20.     '-------------------------------------------------------------------------
  21.     ' Global Variables
  22.     '-------------------------------------------------------------------------
  23.     'frame work variables
  24.     Dim page    
  25.     Dim rc
  26.     
  27.     '
  28.     'Create property page
  29.     Call SA_CreatePage(L_PAGETITLE_CLEAR_TEXT,"",PT_PROPERTY,page)
  30.     Call SA_ShowPage(page)
  31.     
  32.         
  33.     '-------------------------------------------------------------------------
  34.     'Function:                OnInitPage()
  35.     'Description:            Called to signal first time processing for this page.
  36.     '                        Use this method to do first time initialization tasks
  37.     'Input Variables:        PageIn,EventArg
  38.     'Output Variables:        None
  39.     'Returns:                True/False
  40.     'Global Variables:        Out: F_strFileToDelete,F_arrFilesToDelete,F_strFilesPath
  41.     '-------------------------------------------------------------------------
  42.     Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  43.         
  44.         'variables used for getting the selected ots entries
  45.         Dim x
  46.         Dim itemCount
  47.         Dim itemKey
  48.         
  49.         ' get the file to be deleted as Query String from previous page
  50.         If    Instr(1,Request.QueryString(),"Single",1) then
  51.             F_strFileToDelete = Request.QueryString("FilePath")
  52.         Else
  53.              F_strFilesPath =  Request.QueryString("FilePath")
  54.             ' Show a list of the items selected
  55.             itemCount = OTS_GetTableSelectionCount("")
  56.             Redim F_arrFilesToDelete(itemCount-1)            
  57.             For x = 1 to itemCount
  58.                 If ( OTS_GetTableSelection("", x, itemKey) ) Then
  59.                     F_arrFilesToDelete(x-1) = itemKey
  60.                     F_strFilesSubmit = F_strFilesSubmit & itemKey & "|" 
  61.                 End If
  62.             Next    
  63.         End if    
  64.         
  65.         OnInitPage = True
  66.         
  67.     End Function
  68.     
  69.     '-------------------------------------------------------------------------
  70.     'Function:                OnServePropertyPage()
  71.     'Description:            Called when the page needs to be served.Use this 
  72.     '                        method to serve content
  73.     'Input Variables:        PageIn,EventArg
  74.     'Output Variables:        None
  75.     'Returns:                True/False
  76.     'Global Variables:        F_strFilesPath,F_strFileToDelete,L_DELETE_CONFIRM_TEXT
  77.     '-------------------------------------------------------------------------
  78.     Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg) 
  79.         Call SA_ServeDefaultClientScript
  80.         Dim oEncoder
  81.         Set oEncoder = new CSAEncoder
  82.         
  83.     %>
  84.         <table width="100%" border="0" cellspacing="0" cellpadding="0" >
  85.             <tr>
  86.                 <td class="TasksBody">
  87.                     <%=oEncoder.EncodeElement(L_DELETE_CONFIRM_TEXT)%> 
  88.                 </td>
  89.             </tr>
  90.         </table>
  91.         <input type="hidden" name="hdnLogPath" value="<%=Server.HTMLEncode(F_strFilesPath)%>">
  92.         <input type="hidden" name="hdnLogFile" value="<%=Server.HTMLEncode(F_strFileToDelete)%>">
  93.         <input type="hidden" name="hdnDeleteLogFiles" value="<%=Server.HTMLEncode(F_strFilesSubmit)%>">
  94.     <%    
  95.  
  96.         OnServePropertyPage = True
  97.  
  98.     End Function
  99.     
  100.     '-------------------------------------------------------------------------
  101.     'Function:                OnPostBackPage()
  102.     'Description:            Called to signal that the page has been posted-back.
  103.     'Input Variables:        PageIn,EventArg
  104.     'Output Variables:        None
  105.     'Returns:                True/False
  106.     'Global Variables:        None
  107.     '-------------------------------------------------------------------------
  108.     Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  109.         
  110.         ' get the file to be deleted
  111.         F_strFileToDelete = Request.Form("hdnLogFile")
  112.         F_strFilesSubmit = Request.Form("hdnDeleteLogFiles")
  113.         F_arrFilesSubmitToDelete = Split(F_strFilesSubmit,"|")
  114.         
  115.         OnPostBackPage = True
  116.     End Function
  117.         
  118.     '-------------------------------------------------------------------------
  119.     'Function:                OnSubmitPage()
  120.     'Description:            Called when the page has been submitted for processing.
  121.     '                        Use this method to process the submit request.
  122.     'Input Variables:        PageIn,EventArg
  123.     'Output Variables:        None
  124.     'Returns:                True/False
  125.     'Global Variables:        Out: F_strFileToDelete
  126.     '-------------------------------------------------------------------------
  127.     Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  128.        
  129.         If F_strFileToDelete = "" then
  130.             'path of the files to be deleted.    
  131.             F_strFilesPath = Request.Form("hdnLogPath")
  132.             OnSubmitPage = ClearLog("")            
  133.         Else
  134.             OnSubmitPage = ClearLog(F_strFileToDelete)
  135.         End if 
  136.             
  137.     End Function
  138.            
  139.     '-------------------------------------------------------------------------
  140.     'Function:                OnClosePage()
  141.     'Description:            Called when the page is about closed.Use this method
  142.     '                        to perform clean-up processing
  143.     'Input Variables:        PageIn,EventArg
  144.     'Output Variables:        None
  145.     'Returns:                True/False
  146.     'Global Variables:        None
  147.     '-------------------------------------------------------------------------
  148.     Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  149.         OnClosePage = TRUE
  150.     End Function     
  151.     
  152.    
  153.     '-------------------------------------------------------------------------
  154.     'Function name:            ClearLog
  155.     'Description:            Serves in clearing the log files
  156.     'Input Variables:        strLogFileToDelete    
  157.     'Output Variables:        None
  158.     'Returns:                True/False. True if successful else False
  159.     'Global Variables:        F_strFilesPath,F_arrFilesSubmitToDelete,L_*
  160.     'Clears events for the selected log
  161.     '------------------------------------------------------------------------
  162.     Function ClearLog(strLogFileToDelete)
  163.  
  164.         Err.clear
  165.         On Error Resume Next
  166.         
  167.         Dim objFSO            'fso Object
  168.         Dim nRetVal            'variable to get the return value
  169.         Dim x                'variable used for getting the selected ots entries
  170.         Dim itemCount        'variable used for getting the selected ots entries
  171.         Dim strFileDelete    'File to delete
  172.         
  173.         Set objFSO = CreateObject("Scripting.FileSystemObject")
  174.      
  175.         If strLogFileToDelete = "" then
  176.             itemCount = Ubound(F_arrFilesSubmitToDelete)
  177.             For x = 0 to itemCount-1
  178.                 strFileDelete = F_strFilesPath & "\" & F_arrFilesSubmitToDelete(x)
  179.                 If NOT (objFSO.FileExists(strFileDelete)) Then
  180.                     SA_SetErrMsg L_LOGFILE_NOTFOUND_ERRORMESSAGE 
  181.                     ClearLog = False
  182.                     Exit Function
  183.                 End If
  184.                 nRetVal = objFSO.DeleteFile(strFileDelete)
  185.             Next
  186.         Else
  187.             If NOT (objFSO.FileExists(strLogFileToDelete)) Then
  188.                 SA_SetErrMsg L_LOGFILE_NOTFOUND_ERRORMESSAGE
  189.                 ClearLog = False
  190.                 Exit Function
  191.             End If
  192.             nRetVal = objFSO.DeleteFile(strLogFileToDelete)
  193.             Call SA_TraceOut(SA_GetScriptFileName(), "Deleted file: " & strLogFileToDelete)
  194.         End If    
  195.         
  196.         If Err.number <> 0 Then
  197.             SA_SetErrMsg L_SHAREVIOLATION_ERRORMESSAGE 
  198.             ClearLog = False
  199.             Exit Function
  200.         End If
  201.                 
  202.         ClearLog = TRUE
  203.  
  204.         'Release the objects
  205.         Set objFSO = nothing
  206.         
  207.     End function
  208.     
  209. %>
  210.